﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SAKS.IServices;
using SAKS.Models;
using NHibernate;
using NHibernate.Linq;

namespace SAKS.Services
{
    public abstract class DocServicesBase<I, F> : IDocServicesBase<I, F>
    {
        public ISession Session { get; set; }

        public void SaveInfo(I info)
        {
            Session.SaveOrUpdate(info);
        }
        public Guid  SaveFile(F doc)
        {
            return (Guid)Session.Save(doc);
        }

        public F GetFile(Guid fileId)
        {
            return Session.Get<F>(fileId);
        }
        public I GetInfo(Guid infoId)
        {
            return Session.Get<I>(infoId);
        }

        public void DeleteInfo(Guid docinfoId)
        {
            var info = Session.Get<I>(docinfoId);
            Session.Delete(info);
        }   
    }
}
